package BanyuanClub.Study.Day0304;

import java.io.*;

/**
 * 将aaa的奇数行于bbb的偶数行复制到ccc
 */
public class Exc {
    public static void main(String[] args) {
        try(BufferedReader bra = new BufferedReader(new FileReader("aaa,txt"));
            BufferedReader brb = new BufferedReader(new FileReader("bbb.txt"));
            BufferedWriter bw = new BufferedWriter(new FileWriter( "ccc.txt")))
        {
               String str;
               int shu = 0;
               while ((str = bra.readLine()) != null){
                   shu++;
                   if (shu % 2 == 1){
                       bw.write(str);
                       bw.newLine();
                       bw.flush();
                   }
               }
               shu = 0;
                while ((str = bra.readLine()) != null){
                    shu++;
                    if (shu % 2 == 0){
                        bw.write(str);
                        bw.newLine();
                        bw.flush();
                    }
                }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}